package com.bq.server.core.mapper;

import cn.hutool.core.util.StrUtil;
import com.bq.server.base.BaseMapper;
import com.bq.server.core.model.CadreAppointInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author shchen
 */
public interface CadreAppointInfoMapper extends BaseMapper<CadreAppointInfo> {


    default CadreAppointInfo findInfoById(Long cadreId) {
        return this.lambdaQuery()
                .eq(CadreAppointInfo::getId, cadreId)
                .one();
    }

    default List<CadreAppointInfo> findListByIds(List<Long> ids) {
        return this.lambdaQuery()
                .in(CadreAppointInfo::getId, ids)
                .orderByDesc(CadreAppointInfo::getId)
                .list();
    }

    default List<CadreAppointInfo> findInfoByName(String search) {
        if (StrUtil.isEmpty(search)) {
            return new ArrayList<>();
        }
        return this.lambdaQuery()
                .like(CadreAppointInfo::getName, search)
                .orderByDesc(CadreAppointInfo::getId)
                .list();
    }

}